import { _decorator, Component, Node, sp, Vec3 } from "cc";
import { Bullet2 } from "./Bullet2";
const { ccclass, property } = _decorator;

@ccclass("fanBullet")
export class fanBullet extends Bullet2 {
  @property({ type: Vec3 })
  direction: Vec3 = new Vec3(1, 0, 0); // 初始方向向量（如右上方）
  start() {
    Vec3.normalize(this.direction, this.direction);
  }
  update(deltaTime: number) {
    let position = this.node.position;
    // 计算位移：速度 * 时间 * 方向
    const movement = new Vec3();
    Vec3.multiplyScalar(movement, this.direction, Bullet2.speed * deltaTime);
    // 更新节点位置
    const newPos = position.add(movement);
    this.node.setPosition(newPos);
    if (newPos.y > 440) {
      this.node.destroy();
    }
  }
}
